package com.pro.web;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import com.pro.model.ResultMap;
import com.pro.util.BusinessException;
import com.pro.util.ResponseUtil;

import net.sf.json.JSONObject;

@ControllerAdvice
public class ExceptionAdvice {

	@ExceptionHandler(value=BusinessException.class)
	public void businessExceptionHandle(BusinessException ex){
		ex.printStackTrace();
		ResultMap rm = new ResultMap();
		rm.setErrCode(2);
		rm.setErrMsg(ex.getCause1());
		ResponseUtil.write( ex.getResp(), JSONObject.fromObject(rm));
	}
	
	
}
